package top.fwpsl.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.fwpsl.config.properties.RedisClusterProperty;

import javax.annotation.PostConstruct;
import java.util.List;


@Component
public class RedisClusterConfig {

    @Autowired
    private RedisClusterProperty redisClusterProperty;

    public static int maxIdle;
    public static int minIdle;
    public static int maxTotal;
    public static int maxWaitMillis;
    public static int connectionTimeout;
    public static int soTimeout;
    public static int maxAttempts;
    public static List<String> serverHosts;

    @PostConstruct
    public void init() {
        maxIdle = redisClusterProperty.getMaxIdle();
        minIdle = redisClusterProperty.getMinIdle();
        maxTotal = redisClusterProperty.getMaxTotal();
        maxWaitMillis = redisClusterProperty.getMaxWaitMillis();
        connectionTimeout = redisClusterProperty.getConnectionTimeout();
        soTimeout = redisClusterProperty.getSoTimeout();
        maxAttempts = redisClusterProperty.getMaxAttempts();
        serverHosts = redisClusterProperty.getServerHosts();
    }
}
